package context;

import java.io.IOException;

import javax.security.auth.message.callback.PrivateKeyCallback.Request;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/app")
public class ContextServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//得到应用程序上下文
		ServletContext app = this.getServletContext();
		ServletContext app2 = req.getServletContext();
		ServletContext app3 = this.getServletConfig().getServletContext();
		ServletContext app4 = req.getSession().getServletContext();
		System.out.println(app);
		System.out.println(app2);
		System.out.println(app3);
		System.out.println(app4);
		//获取初始化参数
		System.out.println(app.getInitParameter("version"));
	}
}
